using System.Collections.Generic;
using UnityEngine;

public class Createrrain : MonoBehaviour
{
	public Vector2 blocPoolPosition = new Vector2(10f, 3f);

	public float fireTime = 10f;

	public GameObject bloc;

	public float MinPosition;

	public float MaxPosition;

	public int pooledAmount = 3;

	public float xpos;

	public float ypos;

	public float hauteurObjectmin;

	public float hauteurObjectmax;

	public float TimeDepartBloc = 5f;

	public int mirroir;

	private List<GameObject> blocs;

	private void Start()
	{
		blocs = new List<GameObject>();
		for (int i = 0; i < pooledAmount; i++)
		{
			GameObject gameObject = Object.Instantiate(bloc);
			gameObject.SetActive(false);
			blocs.Add(gameObject);
		}
		InvokeRepeating("CreaBlocs", TimeDepartBloc, fireTime);
	}

	private void CreaBlocs()
	{
		ypos = Random.Range(hauteurObjectmin, hauteurObjectmax);
		mirroir = Random.Range(0, 2);
		xpos = Random.Range(MinPosition, MaxPosition);
		if (mirroir != 0)
		{
		}
		for (int i = 0; i < blocs.Count; i++)
		{
			blocPoolPosition.y = ypos;
			blocPoolPosition.x = xpos;
			if (!blocs[i].activeInHierarchy)
			{
				blocs[i].transform.position = blocPoolPosition;
				blocs[i].transform.rotation = base.transform.rotation;
				blocs[i].SetActive(true);
				break;
			}
		}
	}
}
